import { createRouter, createWebHashHistory, RouteLocationNormalized, RouteRecordRaw, } from 'vue-router'
import Aachievement from './views/Activity/achievement.vue'
import Activity from './views/Activity/activity.vue'
import TeamcreatedActivity from './views/Activity/createdactivit.vue'
import Duplicate from './views/Activity/duplicate.vue'
import ActivityCfg from './views/Activity/index.vue'
import ActivityQuestion from './views/Activity/question.vue'
import Asignup from './views/Activity/signup.vue'
import SmsAVue from './views/Activity/sms.vue'
import MatchSummarize from './views/Activity/summarize.vue'
import editActivityQuestion from './views/Activity/WatchActivityQuestion.vue'
import AILog from './views/AILog.vue'
import CourseMgmt from './views/courseMgmt/courseCfg.vue'
import Home from './views/Home.vue'
import Login from './views/Login.vue'
import Acc from './views/Question/acc.vue'
import chgQuestion from './views/Question/chgQuestion.vue'
import question from './views/Question/index.vue'
import myQuestion from './views/Question/myQuestion.vue'
import PermissionsCfg from './views/Question/permissionsCfg.vue'
import publicQuestion from './views/Question/publicQuestion.vue'
import questionDetail from './views/Question/questioninfo.vue'
import teamQuestion from './views/Question/teamQuestion.vue'
import Testcase from './views/Question/testcase.vue'
import vipQuestion from './views/Question/vipQuestion.vue'
import addquestionbank from './views/Questionbank/addquestionbank.vue'
import chgMyQuestionBank from './views/Questionbank/chgMyQuestionBank.vue'
import questionbankindex from './views/Questionbank/index.vue'
import myQuestionbank from './views/Questionbank/myQuestionbank.vue'
import teamQuestionBank from './views/Questionbank/teamQuestionBank.vue'
import Createdteamjob from './views/task/createdteamjob.vue'
import Task from './views/task/task.vue'
import TeamFile from './views/Team/file.vue'
import Team from './views/Team/index.vue'
import TeamCfg from './views/Team/teamCfg.vue'
import Teamid from './views/Team/teamid.vue'
import TeamUser from './views/Team/teamuser.vue'
import Teamusergroup from './views/Team/teamusergroup.vue'
import AIActivitySummarize from './views/Activity/aIActivitySummarize.vue'
import Matchlogs from './components/activity/matchlogs.vue'
import datachat from './views/Team/datachat.vue'
function toID(rote: RouteLocationNormalized): Record<string, any> {
  return {
    ID: Number(rote.params.ID)
  }
}

export const routeCfg: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: { isMenu: false, },
    children: [
      // 基本配置
      {
        path: 'teamCfg',
        name: '基本配置',
        component: TeamCfg,
        meta: { isMenu: true, },
      },
      {
        path: 'teamdatachat',
        name: '团队大数据',
        component: datachat,
        meta: { isMenu: true, },
      },
      {
        path: 'team',
        name: '团队配置',
        component: Teamid,
        meta: { isMenu: true, },
        redirect: to => {
          return { name: '成员配置' }
        },
        children: [
          {
            path: 'teamUser',
            name: '成员配置',
            components: { TeamUser: TeamUser },
            meta: { isMenu: true, },
          },
          {
            path: 'teamUserGroup',
            name: '团队用户组',
            components: { Teamusergroup: Teamusergroup },
            meta: { isMenu: true, },
          },
        ]
      },
      {
        path: 'teamFile',
        name: '资料管理',
        component: TeamFile,
        meta: { isMenu: true, },
      },
      // 课程配置
      {
        path: 'courseMgmt',
        name: '课程配置',
        component: CourseMgmt,
        meta: { isMenu: true, },
      },
      // 题库配置
      {
        path: 'permissionsCfg',
        name: '权限配置',
        component: PermissionsCfg,
        meta: { isMenu: true, },
      },
      {
        path: 'question',
        name: '题目配置',
        component: question,
        meta: { isMenu: true, },
        children: [
          {
            path: 'publicQuestion',
            name: '公开题目',
            components: { publicQuestion: publicQuestion },
            meta: { isMenu: false, },
          },
          {
            path: 'VipQuestion',
            name: '精选题目',
            components: { vipQuestion: vipQuestion },
            meta: { isMenu: false, },
          },
          {
            path: 'teamQuestion',
            name: '团队题目',
            components: { teamQuestion: teamQuestion },
            meta: { isMenu: false, },
          },
          {
            path: 'myQuestion',
            name: '我的题目',
            components: { myQuestion: myQuestion },
            meta: { isMenu: false, },
          },
          {
            path: 'chgQuestion',
            name: '更新题目',
            components: { chgQuestion: chgQuestion },
          },
          {
            path: 'questionDetail/:ID',
            name: '题目详情',
            components: {
              questionDetail: questionDetail,
            },
            // 对于有命名视图的路由，你必须为每个命名视图定义 props 配置
            props: { questionDetail: toID },
            children: [
              {
                path: 'testcase',
                name: '测试点',
                component: Testcase
              },
              {
                path: 'acc',
                name: '题解',
                component: Acc
              },
            ]
          },
        ],
      },
      {
        path: 'questionbank',
        name: '专题配置',
        component: questionbankindex,
        meta: { isMenu: true, },
        redirect: to => {
          return { name: '团队专题' }
        },
        children: [
          {
            path: 'teamQuestionBank',
            name: '团队专题',
            components: { teamQuestionBank: teamQuestionBank },
            meta: { isMenu: false, },
          },
          {
            path: 'myQuestionBank',
            name: '我的专题',
            components: { myQuestionbank: myQuestionbank },
            meta: { isMenu: false, },
          },
          {
            path: 'chgMyQuestionbank/:ID',
            name: '修改我的专题',
            components: { chgMyQuestionbank: chgMyQuestionBank, },
            // props: toID,
          },
        ],
      },
      {
        path: 'addquestionbank',
        name: '添加专题',
        component: addquestionbank,
        meta: { isMenu: true, },
      },
      //   ]
      // },
      // 活动配置：任务、比赛
      // {
      //   path: 'activityMgmt',
      //   name: '活动配置',
      //   component: Activity, // 临时,
      //   meta: { isMenu: true, },
      //   children: [
      // 任务
      {
        path: 'teamTask',
        name: '任务配置',
        component: Task,
        meta: { isMenu: true, },
      },
      {
        path: 'createdteamjob/:ID',
        name: '创建任务',
        component: Createdteamjob,
        props: toID,
      },
      // 比赛
      {
        path: 'activity',
        name: '比赛配置',
        component: ActivityCfg,
        meta: { isMenu: true, },
        children: [],
      },
      {
        path: 'teamactivity/:ID',
        name: '创建比赛',
        component: TeamcreatedActivity,
        props: toID,
      },
      {
        path: 'activity/:ID',
        name: '查看比赛',
        component: Activity,
        meta: { isMenu: true, },
        props: toID,
        redirect: to => {
          return { name: '比赛成绩' }
        },
        children: [
          {
            path: 'achievement',
            name: '比赛成绩',
            component: Aachievement,
            meta: { isMenu: true, },
          },
          {
            path: 'ActivityQuestion',
            name: '比赛题目',
            component: ActivityQuestion,
            meta: { isMenu: true, },
          },
          {
            path: 'editActivityQuestion/',
            name: '修改比赛题目',
            component: editActivityQuestion,
            meta: { isMenu: true, },
          },
          {
            path: 'summarize',
            name: '比赛总结',
            component: MatchSummarize,
            meta: { isMenu: true, },
          },
          {
            path: 'matchlog',
            name: '比赛提交记录',
            component: Matchlogs,
            meta: { isMenu: true, },
          },
          {
            path: 'AIActivitySummarize',
            name: 'AI分析比赛',
            component: AIActivitySummarize,
          },
          // ==============================
          {
            path: 'Duplicate',
            name: '比赛其他功能',
            component: Duplicate,
            meta: { isMenu: true, },
          },
          {
            path: 'Asignup',
            name: '报名用户',
            component: Asignup,
            meta: { isMenu: true, },
          },
          {
            path: 'ASms',
            name: '比赛短信发送',
            component: SmsAVue,
            meta: { isMenu: true, },
          },
          //   ]
          // },
        ]
      },
      {
        path: 'AILog',
        name: '日志(AI)',
        component: AILog,
      },
      // ================== admin后台功能 ==================
      // {
      //   name: '课程管理',
      //   path: 'courses',
      //   component: courses,
      //   meta: { isMenu: true, },
      // },
      // {
      //   name: '课程',
      //   path: 'course/:ID',
      //   component: course,
      //   meta: { isMenu: true, },
      //   props: toID,
      //   redirect: to => {
      //     return { name: '查看课程' }
      //   },
      //   children: [
      //     {
      //       name: '查看课程',
      //       path: 'watchcourse',
      //       component: watchcourse,
      //       meta: { isMenu: true, },
      //     },
      //     {
      //       name: '课程小节s',
      //       path: 'lessions',
      //       component: lessions,
      //       meta: { isMenu: true, },
      //     }
      //   ]
      // },
      // {
      //   name: '课程小节管理',
      //   path: 'coursesections',
      //   component: coursesections,
      //   meta: { isMenu: true, },
      //   props: toID,
      // },
      // {
      //   name: '课程组管理',
      //   path: 'catebags',
      //   component: catebags,
      //   meta: { isMenu: true, },
      // },
      // {
      //   name: '课程组',
      //   path: 'catebag/:ID',
      //   component: catebag,
      //   meta: { isMenu: true, },
      //   props: toID,
      // },
      // 团队
      {
        path: 'teams',
        name: '团队管理',
        component: Team,
        meta: { isMenu: true, },
      },
    ]
  },
  {
    path: '/Login',
    name: 'Login',
    component: Login,
    meta: { isMenu: false, },
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: routeCfg
})

// 

export default router
